﻿using DevComponents.DotNetBar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Public
{
    public partial class Frm_Unlock : Form
    {
        public Frm_Unlock()
        {
            InitializeComponent();
        }

        private void Btn_Esc_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void panel1_Click(object sender, EventArgs e)
        {
            //this.Close();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void panel2_Paint(object sender, PaintEventArgs e)
        {

        }

        private void pwd_KeyDown(object sender, KeyEventArgs e)
        {

            if (e.KeyData != Keys.Enter)
            {
                return;
            }

            
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            if (this.Submit.DialogResult != DialogResult.OK)
            {
                Tools.ShowInformation("请联系管理员解锁！");
                // Nlogger.Info(context.登录用户.FCODE, _程序ID, "解锁", "尝试关闭解锁界面！");
                this.WindowState = FormWindowState.Normal;
                e.Cancel = true;
            }

        }

        private void Submit_Click(object sender, EventArgs e)
        {
            if (pwd.Text.Trim() == "")
            {
                Tools.ShowWaring("请输入解锁密码");
                return;
            }
            else
            {
                string unlock_pwd = ConfigurationManager.AppSettings["unlockPwd"];
                if (pwd.Text == unlock_pwd)
                {
                    Submit.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    Tools.ShowError("密码错误");
                    return;
                }
            }

           
        }

        //private void Frm_Unlock_FormClosing(object sender, FormClosingEventArgs e)
        //{



        //    // 检查关闭事件的原因，如果是用户关闭，则取消关闭
        //    if (e.CloseReason == CloseReason.UserClosing)
        //    {
        //        // 取消关闭
        //        e.Cancel = true;

        //        // 可选：显示一个消息框或其他提示，告诉用户无法关闭窗体
        //        MessageBox.Show("无法关闭窗体！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        //    }
        //}
    }
}
